import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 殇
 * Date: 2025-05-22
 * Time: 21:04
 */
public class Test3 {
    //元素填充
    public static void main(String[] args) {
        int[] arr=new int[10];
        Arrays.fill(arr,1);
        System.out.println(Arrays.toString(arr));
        Arrays.fill(arr,2,8,2);
        System.out.println(Arrays.toString(arr));

    }
    //数组排序
    public static void main3(String[] args) {
        int[] arr=new int[]{11,5,9,2,16,7,10,19,6,0};
        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));
        int[] nums=new int[]{1,2,3,4,5};
        System.out.println(Arrays.equals(arr,nums));
    }
    //数组拷贝
    public static void main2(String[] args) {
        int[] arr=new int[]{1,2,3,4,5};
        //1.使用copeOf进行拷贝
        int[] array1=Arrays.copyOf(arr,arr.length);
        int[] array2=Arrays.copyOf(arr,arr.length);
        //2.使用arraycopy进行拷贝
        int[] array3=new int[arr.length];
        System.arraycopy(array3,0,arr,0,arr.length);
        array3[0]=100;
        for(int x:arr)
            System.out.print(x+" ");
    }
    //数组转字符串
    public static void main1(String[] args) {
        int[] arr=new int[]{1,2,3,4,5};
        //转为字符串数组
        String arrays=Arrays.toString(arr);
        System.out.println(arrays);

    }
}
